/**
 * 订单管理-订单审核
 * 
 * @author yellow
 */
var orderConfirmingMask = new Ext.LoadMask(Ext.getBody(), {
			msg : "正在提交,请稍后..."
		});
var queryOrderCheckSearch = function() {
	var queryOrdersConfirmingFieldSet = new Ext.form.FieldSet({
		id : 'queryOrdersConfirmingFieldSet',
		title : '查询条件',
		collapsible : true,// 可折叠
		buttonAlign : 'center',
		keys : [{
					key : 13, // 13代表回车
					fn : queryOrdersConfirming,
					scope : this
				}],
		items : [{
					layout : 'column',
					border : false,
					items : [{
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{
											xtype : 'textfield',
											name : 'id',
											anchor : '100%',
											fieldLabel : '订单编号'
										}]
							}, {
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{
											id : "orderConfirming_Code",
											xtype : 'textfield',
											anchor : '100%',
											fieldLabel : '订单编码',
											name : "orderCode"
										}]
							}, {
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{
											id : "orderConfirming_userId",
											xtype : 'textfield',
											anchor : '100%',
											fieldLabel : '用户编号',
											name : "userId"
										}]
							}, {
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{
											xtype : 'dataDictionaryCmb',
											anchor : '100%',
											fieldLabel : "支付方式",
											editable : false,
											autoLoad : false,
											existall : true,
											defaultFirstRow : 1,
											hiddenName : 'payType',
											dictionaryType : PmsUtil.orders_pay_type

										}]
							}]
				}, {
					layout : 'column',
					border : false,
					items : [{
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{
											xtype : 'dataDictionaryCmb',
											anchor : '100%',
											fieldLabel : "支付状态",
											editable : false,
											autoLoad : false,
											existall : true,
											defaultFirstRow : 1,
											hiddenName : 'payStatus',
											dictionaryType : PmsUtil.orders_pay_status
										}]
							}, {
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{
											xtype : 'dataDictionaryCmb',
											anchor : '100%',
											fieldLabel : "订单类型",
											editable : false,
											autoLoad : false,
											existall : true,
											defaultFirstRow : 1,
											hiddenName : 'orderType',
											dictionaryType : PmsUtil.order_type
										}]
							}, {
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{
									layout : 'column',
									border : false,
									items : [{
												text : '查询',
												xtype : 'button',
												width : 70,
												handler : function() {
													queryOrdersConfirming();
												},
												style : {
													marginLeft : "50px",
													marginRight : "10px"
												}
											}, {
												text : '重置',
												xtype : 'button',
												width : 70,
												handler : function() {
													queryOrderCheckForm
															.getForm().reset();
												}
											}]
								}]

							}]
				}]
	});
	fieldSetListeners(['queryOrdersConfirmingFieldSet', 'queryOrderCheckForm',
					'orderManagerGrid'], [0.16, 0.84]);

	var queryOrderCheckForm = new Ext.form.FormPanel({
				id : 'queryOrderCheckForm',
				anchor : '100% 16%',
				frame : true,
				labelAlign : 'right',
				bodyBorder : false,
				items : [queryOrdersConfirmingFieldSet]
			});
	return queryOrderCheckForm;
};

/**
 * grids
 */

var orderConfirmingManagerGrid = function() {
	var orderManagerSm = new Ext.grid.CheckboxSelectionModel({
				checkOnly : true,
				renderer : function(v, p, record) {
					var orderStatus = record.get('orderStatus');
					if (orderStatus != PmsUtil.ORDER_STATUS_CONFRIM) {
						return '<div class="x-grid3-row-checker">&#160;</div>';
					} else {
						return '';
					}
				},
				listeners : {
					beforerowselect : function(SelectionModel, rowIndex,
							keepExisting, record) {
						var orderStatus = record.get('orderStatus');
						if (orderStatus != PmsUtil.ORDER_STATUS_CONFRIM) {
							return true;
						} else {
							return false;
						}
					}
				}

			});// 创建选择模式对象
	// 定义表的每列（对应表头信息）
	var orderManagerCm = new Ext.grid.ColumnModel([orderManagerSm, {
				dataIndex : "id",
				header : "订单编号",
				sortable : false,
				width : 60
			}, {
				dataIndex : "orderCode",
				header : "订单编码",
				sortable : false,
				width : 160,
				renderer : function(value, cellmeta, record, rowIndex,
						columnIndex, store) {
					var returnValue = "";
					var orderId = record.data.id;
					if (value) {
						returnValue = '<a href ="#" onClick="lookOrderDetail(\''
								+ orderId + '\')">' + value + '</a>';
					}
					return returnValue;
				}
			}, {
				dataIndex : "userId",
				header : "用户编号",
				sortable : false,
				width : 70
			}, {
				dataIndex : "userName",
				header : "用户姓名",
				sortable : false,
				width : 60
			}, {
				dataIndex : "orderType",
				header : "订单类型",
				sortable : false,
				width : 70,
				renderer : function(value) {
					return PmsUtil.OrderType(value);
				}
			}, {
				dataIndex : "orderStatus",
				header : "订单状态",
				sortable : false,
				width : 60,
				renderer : function(value) {
					if (value) {
						return '<font color=\"#FF0000\" >'
								+ PmsUtil.OrderStatus(value) + '</font>';
					}
				}
			}, {
				dataIndex : "deliveryDate",
				header : "配送日期",
				sortable : false,
				width : 90,
				renderer : function(date) {
					return '<font color=\"#FF0000\" >'
							+ Ext.util.Format.substr(date, 0, 10) + '</font>';
				}
			}, {
				dataIndex : "deliveryTimes",
				header : "配送时间段",
				sortable : false,
				width : 90,
				renderer : function(value) {
					return '<font color=\"#FF0000\" >' + value + '</font>';
				}
			}, {
				dataIndex : "payStatus",
				header : "支付状态",
				sortable : false,
				width : 60,
				renderer : function(value) {
					return PmsUtil.OrderPayStatus(value);
				}
			}, {
				dataIndex : "goodsNumber",
				header : "商品数量",
				sortable : false,
				width : 60
			}, {
				dataIndex : "totalAmount",
				header : "订单总金额",
				sortable : false,
				width : 80,
				renderer : function(value) {
					return Ext.util.Format.number(value, '0,0.00');
				}
			}, {
				dataIndex : "payAmount",
				header : "实际支付金额",
				sortable : false,
				width : 100,
				renderer : function(value) {
					return PmsUtil.Price(value);
				}
			}, {
				dataIndex : "couponFee",
				header : "优惠金额",
				sortable : false,
				width : 60,
				renderer : function(value) {
					return PmsUtil.Price(value);
				}
			}, {
				dataIndex : "deliveryFee",
				header : "配送费用",
				sortable : false,
				width : 60,
				renderer : function(value) {
					return PmsUtil.Price(value);
				}
			}, {
				dataIndex : "userPaymentId",
				header : "支付流水ID",
				sortable : false,
				width : 80
			}, {
				dataIndex : "payDate",
				header : "支付时间",
				sortable : false,
				width : 130
			}, {
				dataIndex : "payType",
				header : "支付方式",
				sortable : false,
				width : 60,
				renderer : function(value) {
					return PmsUtil.PayType(value);

				}
			}, {
				dataIndex : "couponId",
				header : "优惠ID",
				sortable : false,
				width : 100
			}, {
				dataIndex : "couponType",
				header : "优惠类型",
				sortable : false,
				width : 60,
				renderer : function(value) {
					return PmsUtil.CouponType(value);
				}
			}, {
				dataIndex : "couponCode",
				header : "优惠码",
				sortable : false,
				width : 90
			}, {
				dataIndex : "couponSource",
				header : "优惠来源",
				sortable : false,
				width : 90
			}, {
				dataIndex : "consignee",
				header : "收货人",
				sortable : false,
				width : 60
			}, {
				dataIndex : "consignPhone",
				header : "收货人电话",
				sortable : false,
				width : 100
			}, {
				dataIndex : "consignAddress",
				header : "收货人地址",
				sortable : false,
				width : 150,
				renderer : function(value, meta, record) {
					if (value) {
						meta.attr = 'ext:qtitle="收货人地址:" ext:qtip="' + value
								+ '"';
						return value;
					}
				}
			}, {
				dataIndex : "birthdayCard",
				header : "生日卡片",
				sortable : false,
				width : 80,
				renderer : function(value) {
					if (value) {
						var div = '<div ext:qtitle="生日卡片:" ext:qtip="{0}">{0}</div>';
						return String.format(div, value);
					}
				}
			}, {
				dataIndex : "remark",
				header : "备注",
				sortable : false,
				width : 100,
				renderer : function(value, meta, record) {
					if (value) {
						meta.attr = 'ext:qtitle="备注:" ext:qtip="' + value + '"';
						return value;
					}
				}
			}, {
				dataIndex : "createdDate",
				header : "创建时间",
				sortable : false,
				width : 130
			}, {
				dataIndex : "createdName",
				header : "创建人",
				sortable : false,
				width : 60
			}, {
				header : "管理",
				width : 300,
				dataIndex : "id",
				renderer : function(j, i, g, m, h) {
					var orderId = g.data.id;
					var orderStatus = g.data.orderStatus;
					var payType = g.data.payType;
					var payStatus = g.data.payStatus;
					var orderType = g.data.orderType;
					var payAmount = g.data.payAmount;
					var k = "";
					if (orderStatus == 1 && isGranted("orderConfirming_确认订单")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="updateOrderStatusOne('
								+ orderId
								+ ','
								+ "2"
								+ ','
								+ "'已确认'"
								+ ')\">订单确认</a>';
					}
					if ((orderStatus == 0 || orderStatus == 1)
							&& isGranted("orderConfirming_修改订单")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="updCheckOrder('
								+ orderId + ')\">修改订单</a>';
					}
					if (orderStatus == 1 && isGranted("orderConfirming_订单详情")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="lookOrderDetail('
								+ orderId + ')\">订单详情</a>';
					}

					if (orderStatus == 1 && isGranted("orderConfirming_物流状态")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="lookLogisticStatus('
								+ orderId + ')\">物流状态</a>';
					}

					if ((orderStatus == 0 || orderStatus == 1)
							&& (orderType == 3 || orderType == 2)
							&& isGranted("orderConfirming_取消订单")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="cancelOrderStatusRemarks('
								+ orderId + ')\">取消订单</a>';
					}

					if (isGranted("orderConfirming_退款申请")) {
						if (orderStatus == 1 && payStatus == 1
								&& orderType != 3 && orderType != 2) {
							k += '&nbsp;&nbsp;<a href="#" onclick="orderRefunds('
									+ orderId
									+ ",'"
									+ payAmount
									+ "','"
									+ orderStatus + "')\"\">退款申请</a>";
						}
					}
					return k;
				}
			}]);

	// 定义分析器
	var orderManagerReader = new Ext.data.JsonReader({
				totalProperty : "totalCount",
				root : "list",
				fields : [{
							name : "id"
						}, {
							name : "orderCode"
						}, {
							name : "userId"
						}, {
							name : "userName"
						}, {
							name : "userPaymentId"
						}, {
							name : "orderStatus"
						}, {
							name : "payStatus"
						}, {
							name : "payType"
						}, {
							name : "payDate"
						}, {
							name : "limitPayDate"
						}, {
							name : "totalAmount"
						}, {
							name : "goodsNumber"
						}, {
							name : "payAmount"
						}, {
							name : "deliveryDate"
						}, {
							name : "deliveryTimes"
						}, {
							name : "deliveryFee"
						}, {
							name : "couponType"
						}, {
							name : "couponCode"
						}, {
							name : "couponSource"
						}, {
							name : "couponId"
						}, {
							name : "couponFee"
						}, {
							name : "consignee"
						}, {
							name : "consignPhone"
						}, {
							name : "consignAddress"
						}, {
							name : "birthdayCard"
						}, {
							name : "remark"
						}, {
							name : "payGoodsName"
						}, {
							name : "cancelDate"
						}, {
							name : "cancelReason"
						}, {
							name : "createdDate"
						}, {
							name : "createdName"
						}, {
							name : "cancelName"
						}, {
							name : 'orderType'
						}]
			});

	// 取数据store
	var orderViewStore = new Ext.data.Store({
				autoLoad : true,// 要加载数据必须设置为true
				proxy : new Ext.data.HttpProxy({
							url : __ctxPath + "/orderManager/selectOrders"
						}),
				remoteSort : true,
				baseParams : {
					start : 0,
					limit : 25,
					orderStatus : '1',
					orderParam : 'id'
				},
				listeners : {
					beforeload : {
						fn : function(thiz, options) {
							Ext.apply(thiz.baseParams, Ext
											.getCmp('queryOrderCheckForm')
											.getForm().getValues());
						}
					}
				},
				reader : orderManagerReader
			});
	orderViewStore.setDefaultSort("od.delivery_date,od.delivery_times", "asc");
	var orderConfirmingTb = new Ext.Toolbar({// 定义grid的toolbar
		height : 25,
		items : []
	});
	orderConfirmingTb.add(new Ext.scm.Button({
				text : "批量确认",
				width : 80,
				pressed : true,
				hsValue : 'orderConfirming_批量确认',
				iconCls : "btn-edit",
				listeners : {
					"click" : function() {
						batchOrderUpdateStatus(2, '已确认');
					}
				}
			}));
	orderConfirmingTb.add(new Ext.Toolbar.Spacer());
	orderConfirmingTb.add(new Ext.scm.Button({
				text : "刷 新",
				iconCls : "btn-refresh",
				width : 80,
				hsValue : 'orderConfirming_刷新',
				pressed : true,
				handler : function() {
					queryOrdersConfirming();
				}
			}));
	var orderConfirmingManagerGrid = new Ext.grid.GridPanel({
				id : 'orderConfirmingManagerGrid',
				store : orderViewStore,
				cm : orderManagerCm,
				sm : orderManagerSm,
				autoScroll : true,
				loadMask : true,
				stripeRows : true,
				columnLines : true,
				loadMask : {
					msg : "正在加载数据，请稍侯……"
				},
				viewConfig : {
					emptyText : '没有您想要的数据!'
				},
				anchor : '100% 84%',
				frame : true,
				tbar : orderConfirmingTb,
				bbar : new PG.PagingBar({
							id : 'orderConfirmingGridPage',
							store : orderViewStore
						})
			});
	return orderConfirmingManagerGrid;
};

// 查询
function queryOrdersConfirming() {
	PmsUtil.StringTrim("orderConfirming_Code");
	if (Ext.getCmp('queryOrderCheckForm').getForm().isValid()) {
		var grid = Ext.getCmp('orderConfirmingManagerGrid');
		var store = grid.store;
		var pagesize = Ext.getCmp('orderConfirmingGridPage').pageSize;
		store.load({
					params : {
						start : 0,
						limit : pagesize,
						"orderStatusArray" : '0,1,2'
					}
				});
	}
}

// 修改
function updCheckOrder(orderId) {
	Ext.Loader.load([__ctxPath + '/js/order/orderForm.js'], function() {
				updateOrderWin(orderId, 'orderConfirmingManagerGrid').show();
			});
}

/**
 * 查询订单详情
 * 
 * @param {}
 *            id
 */
function lookOrderDetail(id) {
	var centerPanel = App.getContentPanel();
	var tab = centerPanel.getItem(PmsUtil.ORDER_MESSAGE_DETAIL);
	var createNewTab = new CreatNewTab(PmsUtil.ORDER_MESSAGE_DETAIL, '订单详情');
	if (tab == null) {
		createNewTab.createNew(tab);
	} else {
		createNewTab.createOld(tab, ['lookOrderDetailFields',
						'lookOrderDetailForm', 'lookOrderDetailGrid']);
	}
	Ext.Loader.load([__ctxPath + '/js/order/orderDetail.js'], function() {
				Ext.getCmp("centerTabPanel").getActiveTab().add(
						lookOrderDetailSearch(id), orderDetailGrid(id));
				Ext.getCmp("centerTabPanel").getActiveTab().doLayout();
			});
}

/**
 * 查询物流状态列表
 * 
 * @param {}
 *            id
 */
function lookLogisticStatus(id) {
	var centerPanel = App.getContentPanel();
	var tab = centerPanel.getItem(PmsUtil.LOGISTIC_STATUS);
	var createNewTab = new CreatNewTab(PmsUtil.LOGISTIC_STATUS, '物流状态');
	if (tab == null) {
		createNewTab.createNew(tab);
	} else {
		createNewTab.createOld(tab, ['logisticStatusGrid']);
	}
	Ext.Loader.load([__ctxPath + '/js/order/logisticStatus.js'], function() {
		Ext.getCmp("centerTabPanel").getActiveTab().add(logisticStatusGrid(id));
		Ext.getCmp("centerTabPanel").getActiveTab().doLayout();
	});
}

/**
 * 批量修改订单状态
 */
function batchOrderUpdateStatus(orderStatus, statusName) {
	var d = Ext.getCmp("orderConfirmingManagerGrid");
	var jsonrecord = d.getSelectionModel().getSelections();
	if (jsonrecord.length == 0) {
		Ext.MessageBox.show({
					title : "操作信息",
					msg : "请选择要确认的订单!",
					buttons : Ext.MessageBox.OK,
					icon : Ext.MessageBox.WARNING
				});
		return;
	}
	Ext.Msg.confirm("信息确认", "您确定要将订单状态变更为<span style='color:#F00'>"
					+ statusName + "</span>？", function(c) {
				if (c == "yes") {
					var orderIds = "";
					var m = 0;
					for (var i = 0; i < jsonrecord.length; i++) {
						var tmp = jsonrecord[i];
						if (m > 0) {
							orderIds = orderIds + "," + tmp.data.id;
						} else {
							orderIds = tmp.data.id;
						}
						m++;
					}
					commonOrderUpateOrder(orderIds, orderStatus, statusName);
				}
			});
}

/**
 * 订单单个确认
 * 
 * @param {}
 *            orderId
 * @param {}
 *            orderStatus
 * @param {}
 *            statusName
 */
function updateOrderStatusOne(orderId, orderStatus, statusName) {
	Ext.Msg.confirm("信息确认", "您确定要将订单状态变更为<span style='color:#F00'>"
					+ statusName + "</span>？", function(c) {
				if (c == "yes") {
					commonOrderUpateOrder(orderId, orderStatus, statusName);
				}
			});
}
/**
 * 公用修改订单状态方法
 * 
 * @param {}
 *            orderIds
 * @param {}
 *            orderStatus
 * @param {}
 *            statusName
 */
function commonOrderUpateOrder(orderIds, orderStatus, statusName) {
	orderConfirmingMask.show();
	Ext.Ajax.request({
				url : __ctxPath + "/orderManager/updateOrderStatus",
				params : {
					orderIds : orderIds,
					orderStatus : orderStatus,
					statusName : statusName,
					cancelReason : ''
				},
				method : "post",
				success : function(response, config) {
					orderConfirmingMask.hide();
					var jsonData = Ext.util.JSON.decode(response.responseText);
					if (jsonData.success) {
						Ext.MessageBox.show({
									title : "信息提示",
									msg : jsonData.data,
									buttons : Ext.MessageBox.OK,
									icon : Ext.MessageBox.INFO
								});
						queryOrdersConfirming();
					} else {
						Ext.MessageBox.show({
									title : "操作信息",
									msg : jsonData.data,
									buttons : Ext.MessageBox.OK,
									icon : Ext.MessageBox.ERROR
								});
					}
				},
				failure : function(response, config) {
					orderConfirmingMask.hide();
					Ext.MessageBox.show({
								title : "错误提示",
								msg : "服务器请求异常，请稍后再试!",
								buttons : Ext.MessageBox.OK,
								icon : Ext.MessageBox.ERROR
							});
				}
			});
}
/**
 * 取消订单
 * 
 * @param {}
 *            orderId
 */
function cancelOrderStatusRemarks(orderId) {
	cancelOrderStatusRemarksWindows(orderId).show();
}

/**
 * 取消订单
 * 
 * @param {}
 *            orderId
 * @return {}
 */
function cancelOrderStatusRemarksWindows(orderId) {
	var orderForm = new Ext.FormPanel({
				id : "orderForm",
				frame : true,
				bodyBorder : false,
				defaults : {
					widht : 300,
					height : 120,
					anchor : "100%,100%"
				},
				defaultType : "textarea",
				items : [{
							name : "id",
							xtype : "hidden",
							value : orderId
						}, {
							fieldLabel : "取消原因备注",
							name : "cancelReason",
							allowBlank : false,
							vtype : "validateMaxLength",
							confirmTo : 500
						}]
			});
	var orderStatusWindow = new Ext.Window({
		id : "orderStatusWindow",
		title : "取消备注",
		width : 400,
		height : 220,
		closable : true,
		modal : true,
		layout : "fit",
		autoDestroy : true,
		plain : true,
		buttonAlign : "center",
		items : orderForm,
		buttons : [{
			text : "保存",
			width : 60,
			handler : function() {
				var uploadForm = orderForm.getForm();
				if (uploadForm.isValid()) {
					Ext.Msg.confirm("信息确认", "确认要取消该订单吗？", function(c) {
						if (c == "yes") {
							uploadForm.submit({
								url : __ctxPath
										+ "/orderManager/updateOrderStatus",
								params : {
									orderIds : orderId,
									orderStatus : 6,
									statusName : '已取消'
								},
								method : "post",
								waitTitle : "请稍后",
								waitMsg : "正在提交数据...",
								success : function(response, options) {
									queryOrdersConfirming();
									orderStatusWindow.close();
									var jsonData = Ext.util.JSON
											.decode(options.response.responseText);
									Ext.MessageBox.show({
												title : "信息提示",
												msg : jsonData.data,
												buttons : Ext.MessageBox.OK,
												icon : Ext.MessageBox.INFO
											});
								},
								failure : function(response, options) {
									var jsonData = Ext.util.JSON
											.decode(options.response.responseText);
									Ext.MessageBox.show({
												title : "操作信息",
												msg : jsonData.data,
												buttons : Ext.MessageBox.OK,
												icon : Ext.MessageBox.ERROR
											});
									orderStatusWindow.close();
								}
							});
						}
					})
				}
			}
		}, {
			text : "重置",
			width : 60,
			handler : function() {
				orderForm.form.reset();
			}
		}, {
			text : "取消",
			width : 60,
			handler : function() {
				orderStatusWindow.close();
			}
		}]
	});
	return orderStatusWindow;
}

// 退款申请
function orderRefunds(orderId, payAmount, orderStatus) {
	orderRefundsRemarkWindows(orderId, payAmount, orderStatus).show();
}

function orderRefundsRemarkWindows(orderId, payAmount, orderStatus) {
	var orderRefundsForm = new Ext.FormPanel({
		id : "orderRefundsForm",
		frame : true,
		bodyBorder : false,

		items : [{
					name : "id",
					xtype : "hidden",
					value : orderId
				}, {
					xtype : "displayfield",
					id : 'orderForm_payAmount',
					fieldLabel : "最大申请退款金额",
					ctCls : 'zhaospaceCSS3',
					name : "payAmount",
					value : payAmount,
					anchor : '100%'
				}, new Ext.form.NumberField({
							xtype : 'textfield',
							name : 'refundsPrice',
							fieldLabel : "<span style='color:#F00'>*</span>申请退款金额",
							allowBlank : false,
							blankText : '申请退款金额不能为空',
							maxValue : payAmount, // 最大值
							maxText : '申请金额超出最大申请退款金额',
							minValue : 0.1, // 最小值
							minText : '申请退款金额应大于0.1',
							anchor : '100%'
						}), {
					xtype : "textarea",
					fieldLabel : "申请退款原因",
					name : "cancelReason",
					vtype : "validateMaxLength",
					confirmTo : 500,
					anchor : '100%',
					height : 120
				}]
	});
	var orderRefundsWindow = new Ext.Window({
		id : "orderRefundsWindows",
		title : "退款申请",
		width : 400,
		height : 280,
		closable : true,
		modal : true,
		layout : "fit",
		autoDestroy : true,
		plain : true,
		buttonAlign : "center",
		items : orderRefundsForm,
		buttons : [{
			text : "保存",
			width : 60,
			handler : function() {
				var uploadForm = orderRefundsForm.getForm();
				if (uploadForm.isValid()) {
					Ext.Msg.confirm("信息确认", "确认要申请退款吗？", function(c) {
						if (c == "yes") {
							uploadForm.submit({
								url : __ctxPath
										+ "/orderManager/updateOrderStatus",
								params : {
									orderIds : orderId,
									orderStatus : 7,
									statusName : '已申请退款',
									beforeRefundOrderStatus : orderStatus
								},
								method : "post",
								waitTitle : "请稍后",
								waitMsg : "正在提交数据...",
								success : function(response, options) {
									queryOrdersConfirming();
									orderRefundsWindow.close();
									var jsonData = Ext.util.JSON
											.decode(options.response.responseText);
									Ext.MessageBox.show({
												title : "信息提示",
												msg : jsonData.data,
												buttons : Ext.MessageBox.OK,
												icon : Ext.MessageBox.INFO
											});
								},
								failure : function(response, options) {
									var jsonData = Ext.util.JSON
											.decode(options.response.responseText);
									Ext.MessageBox.show({
												title : "操作信息",
												msg : jsonData.data,
												buttons : Ext.MessageBox.OK,
												icon : Ext.MessageBox.ERROR
											});
									orderRefundsWindow.close();
								}
							});
						}
					})
				}
			}
		}, {
			text : "重置",
			width : 60,
			handler : function() {
				orderRefundsForm.form.reset();
			}
		}, {
			text : "取消",
			width : 60,
			handler : function() {
				orderRefundsWindow.close();
			}
		}]
	});
	return orderRefundsWindow;

}

Ext.getCmp("centerTabPanel").getActiveTab().add(queryOrderCheckSearch(),
		orderConfirmingManagerGrid());
Ext.getCmp("centerTabPanel").getActiveTab().doLayout();
